﻿using System;
using System.Web.Mvc;
using Icms.Core.Model;
using Icms.Core.Repository;
using Omu.Awesome.Mvc;

namespace Icms.WebUI.Controllers
{
    public class CourtLookupController : LookupController
    {
        private readonly IRepo<Court> r;

        public CourtLookupController(IRepo<Court> r)
        {
            this.r = r;
        }

        [HttpPost] 
        public ActionResult Search(string search)
        {
            search = (search ?? "").ToLower();
            return  View(@"Awesome\LookupList",r.Where(o => o.Title.ToLower().Contains(search)));
        }

        public ActionResult Get(Guid id)
        {
            return Content((r.Get(id) ?? new Court()).Title);
        }
    }
}